<template>
    <el-container>
          <el-header >
            <Tabs :userName="userName"/>
          </el-header>
    <HeaderTop :flag="true"/>
    <el-main>
      <el-row class="title"> <h3 >【海尔】密园小农 密云当地新鲜西红柿 约2kg 自然熟 沙瓤 新鲜蔬菜</h3> </el-row>
      <el-row class="main-box">
        <div class="main-middle-box">
          <div class="left">
            <div class="left-left">
              <img  src="http://10.203.0.101:8081/shopping/resources/upload/97812ce7d175451484ce43705ad6d5c3.jpg" alt="">
            </div>
            <div class="left-right">
              <el-row>
                <el-col :span="12"> 
                  <span class="oldPrice">市场价:￥90</span>
                  <span class="newPrice">￥67.5</span>
                </el-col>
                <el-col :span="2" :offset="9">
                <el-button icon="el-icon-star-on" circle></el-button>
                </el-col>
              </el-row>
              <hr>
              <el-row>
                <el-col :span="12"> 
                  <span>商品简介:</span>
                </el-col>
                <el-col :span="4" :offset="8">
                  <span class="el-icon-check">有货</span>
                </el-col>
              </el-row>
              <hr>
              <el-row class="btn-box">
                <el-col :span="6" class="num-text" :offset="2">购买数量:</el-col>
                <el-col :span="16" class="btn-input">
                  <CountButton/>
                </el-col>
              </el-row>
              <el-row :gutter="20" class="button-box">
                <el-col :span="4" :offset="4"><el-button class="btn1">加入购物车</el-button></el-col>
                <el-col :span="4" :offset="4"><el-button class="btn2">立即购买</el-button></el-col>
              </el-row>
            </div>
          </div>
          <div class="right">
            <el-row class="rihgt-top">
              <el-col><h4>热销商品</h4></el-col>
            </el-row>
            <div class="right-bottom">
              <el-row class="item-box">
                <el-col :span="8" class="commodity-img" >
                    <img  width="100%" height="100%" src="http://10.203.0.101:8081/shopping/resources/upload/2020-02-24/17d7c8ea166a03fc128aedbb852ae01c.jpg" alt="">
                </el-col>
                <el-col :span="16">
                  <el-row class="commodity-title">新鲜冬枣 1500g 礼盒装 大荔冬枣 水果礼盒 新鲜水果 冬枣 顺丰快递发货 3斤礼盒装</el-row>
                  <el-row class="commodity-new-price">￥147.21</el-row>
                  <el-row class="commodity-old-price">市场价:￥196.22</el-row>
                </el-col>
              </el-row>
            </div>
          </div>
        </div>
        <div class="main-footer-box">
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="商品描述" name="商品描述">寻真水果 山东烟台栖霞红富士苹果16-24个 5kg 新鲜水果1</el-tab-pane>
            <el-tab-pane label="商品评论" name="second">
              <el-card class="box-card"  v-for="(item,index) in comment" :key="index">
                <el-row>
                  <el-col :span="4"> 17767746537 –– </el-col>
                  <el-col :span="10">
                    <el-rate
                      v-model="item.value"
                      disabled
                      show-score
                      text-color="#ff9900"
                      score-template="{value}">
                    </el-rate>
                  </el-col>
                </el-row>
                <el-row class="comment-text">{{item.commentText}}</el-row>
              </el-card>

              <el-card>
                  <h4 slot="header">添加评论</h4>
                  <el-row>
                    <el-col>
                      <el-input v-model="commentContent" placeholder="评论内容"></el-input>
                    </el-col>
                  </el-row>
                  <el-row class="rate-box">
                      <el-rate v-model="commentValue"></el-rate>
                  </el-row>
                  <el-row class="commit-box">
                    <el-col :span="4" :offset="20">
                      <el-button type="primary" @click="commit()" ><i class="el-icon-edit"></i> 提交</el-button>
                    </el-col>
                  </el-row>
              </el-card>
            </el-tab-pane>
          </el-tabs>
        </div>
      </el-row>
    </el-main>
    <el-footer >
        全国高职院校Web应用软件开发技能竞赛
    </el-footer>
    </el-container>
</template>

<script>
import CountButton from '../CountButton/CountButton.vue'
import HeaderTop from '../HeaderTop/HeaderTop.vue'
import Tabs from '../Tabs/Tabs.vue'
export default {
  name:'Product',
  components: { HeaderTop, Tabs, CountButton },
  data(){
    return {
      activeName: '商品描述',
      
      comment:[
        {
          commentText:'针不错',
          value:5
        },
        {
          commentText:'针不错',
          value:4.7
        }
      ],
      commentContent:'',
      commentValue: 0,
      userName:'',
    }
  },
  methods:{
    handleClick(tab, event) {
      console.log(tab, event);
    },
    commit(){
      let commentText = this.commentContent
      let value = this.commentValue
      console.log(commentText,value)
      if ( !(commentText && value) ){
        this.$message('内容或评分不能为空')
        return
      }
      this.comment.push({commentText,value})
      this.$message({
        type:'success',
        message:'添加成功'
      })
    }
  },
  mounted(){
    let name =  localStorage.getItem('userName') 
    this.userName = name
  }

}
</script>

<style scoped>
  .el-container{
    position: relative;
    min-height: 100%;
  }
  .el-main{
    padding: 0px;
  }
  .main-box{
    padding: 0px 80px;
  }
  .title{
    margin: 50px 0;
    max-height: 68px;
    overflow: hidden;
    background: rgba(0,0,0,0.05);
  }
  .title h3{
    padding: 0px 85px;
    height: 68px;
    line-height: 68px;
  }
  .main-middle-box{
    margin-bottom: 100px;
    display: flex;
    justify-content: space-between;
  }
  .left{
    display: flex;
    justify-content: space-between;
    width: 70%;
  }
  .left-left{
    width: 45%;
    border: 1px solid rgba(129, 128, 128, 0.452);
  }
  .left-right{
    width: 45%;
  }
  .oldPrice{
    line-height: 40px;
    display: inline-block;
    padding-right:10px ;
    text-decoration:line-through;
    color: #999;
  }
  .newPrice{
    line-height: 40px;
    font-size: 20px;
    color: black;
  }
  .num-text{
    height: 40px;
    line-height: 40px;
  }
  .input-number{
    width: 80px;
    text-align: center;
  }
  .button-box{
    margin-top: 15px;
  }
  .btn1{
    color:  #E6A23C ;
    border: 1px solid  #E6A23C ;
  }
  .btn2{
    color:  #F56C6C ;
    border: 1px solid  #F56C6C ;
  }
 
  .right{
    width: 25%;
  }
  .rihgt-top{
   border-bottom:rgba(0,0,0,0.2) 1px dashed;
   margin-bottom: 10px;
  }
  .rihgt-top h4{
    margin: 0;
    padding: 00;
  }
  .item-box{
    height: 100px;
    margin-bottom: 10px;
  }
  .commodity-img{
    height: 100%;
    border: 1px solid #999;
  }
  .commodity-title{
    font-size: 12px;
    color: #F07057;
  }
  .commodity-new-price{
    font-size: 18px;
    color: #666;
  }
  .commodity-old-price{
    font-size: 14px;
    columns: #666;
    text-decoration: line-through;
  }  

  .comment-text{
    margin: 20px 0px;
  }
  .el-card{
    padding: 20px 0px;
  }
  .rate-box{
    margin: 20px 0px;
  }
  .commit-box{
    margin-bottom: 20px;
  }

  .main-footer-box{
    width: 70%;
  }


  .el-footer{
    /* position: relative; */
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #bfa;
    text-align: center;
    line-height: 50px;
  }

  
</style>